//
//  CLBaseViewController.m
//  Class_IOS
//
//  Created by peter on 14-8-20.
//  Copyright (c) 2014年 qiuyang. All rights reserved.
//

#import "CLBaseViewController.h"

@interface CLBaseViewController ()

@end

@implementation CLBaseViewController

- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
        _tableView.backgroundColor = [UIColor clearColor];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorColor = [UIColor clearColor];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    
    return _tableView;
}

- (id)init
{
    self = [super init];
    if (self) {
        [self setTableViewDataSource:@[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8"]];
        
    }
    return self;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/


#pragma  mark uitableviewdelegate methods
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
//    UIViewController *baseForHomeVC = [[CLHomeViewController alloc] tabBarController];
//    baseForHomeVC.navigationItem.title = _tableViewDataSource[[indexPath row]];
//    UINavigationController *baseNavController = [[UINavigationController alloc] initWithRootViewController:baseForHomeVC];
//    self.drawerController.homeViewController = baseNavController;
    self.navigationItem.title = _tableViewDataSource[[indexPath row]];
    [self.drawerController endDrawerController:YES velocity:20.0f completion:^(BOOL finished){}];
}

#pragma  mark uitableviewdatasource methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_tableViewDataSource count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"cellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.backgroundColor = [UIColor grayColor];
    cell.textLabel.text = [_tableViewDataSource objectAtIndex:[indexPath row]];
    cell.selectedBackgroundView = [UIView new];
    cell.textLabel.highlightedTextColor = [UIColor redColor];
    
    return cell;
}


@end
